﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="MatchmakingPartnerType.cs" company="DissingNelleman">
//   
// All rights reserved. </copyright>
// <summary>
//   The matchmaking partner type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace ServiceLibrary.Services.Dto
{
    using System;
    using System.Runtime.Serialization;

    /// <summary>
    /// The matchmaking partner type.
    /// </summary>
    [DataContract]
    public class MatchmakingPartnerType
    {
        #region Public Properties

        /// <summary>
        /// Gets or sets the id.
        /// </summary>
        [DataMember]
        public Guid ID { get; set; }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        [DataMember]
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether show other text.
        /// </summary>
        [DataMember]
        public bool ShowOtherText { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether show product development text.
        /// </summary>
        [DataMember]
        public bool ShowProductDevelopmentText { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether show sales text.
        /// </summary>
        [DataMember]
        public bool ShowSalesText { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether show test text.
        /// </summary>
        [DataMember]
        public bool ShowTestText { get; set; }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// The convert.
        /// </summary>
        /// <param name="matchmakingPartnerType">
        /// The matchmaking partner type.
        /// </param>
        /// <returns>
        /// The <see cref="MatchmakingPartnerType"/>.
        /// </returns>
        public static MatchmakingPartnerType Convert(Models.Domain.MatchmakingPartnerType matchmakingPartnerType)
        {
            if (matchmakingPartnerType != null)
            {
                var dto = new MatchmakingPartnerType
                              {
                                  ID = matchmakingPartnerType.ID, 
                                  Name = matchmakingPartnerType.Name, 
                                  ShowOtherText = matchmakingPartnerType.ShowOtherText, 
                                  ShowProductDevelopmentText =
                                      matchmakingPartnerType.ShowProductDevelopmentText, 
                                  ShowSalesText = matchmakingPartnerType.ShowSalesText, 
                                  ShowTestText = matchmakingPartnerType.ShowTestText
                              };
                return dto;
            }
            
            return null;
        }

        #endregion
    }
}

namespace ServiceLibrary.Services.Queries
{
    using System.Runtime.Serialization;

    using NHibernate;

    using ServiceLibrary.Actioners.Activities;
    using ServiceLibrary.Services.Results;

    /// <summary>
    /// The matchmaking partner type query.
    /// </summary>
    [DataContract]
    public class MatchmakingPartnerTypeQuery : IQuery
    {
        #region Public Methods and Operators

        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="hsession">
        /// The hsession.
        /// </param>
        /// <returns>
        /// The <see cref="IResult"/>.
        /// </returns>
        public override IResult Execute(ISession hsession)
        {
            var actioner = new MatchmakingPartnerActioner(hsession, null);

            return actioner.QueryAllPartnerTypes(this);
        }

        #endregion
    }
}

namespace ServiceLibrary.Services.Results
{
    using System.Collections.Generic;
    using System.Runtime.Serialization;

    using ServiceLibrary.Services.Dto;

    /// <summary>
    /// The matchmaking partner type result.
    /// </summary>
    [DataContract]
    public class MatchmakingPartnerTypeResult : IResult
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="MatchmakingPartnerTypeResult"/> class.
        /// </summary>
        public MatchmakingPartnerTypeResult()
        {
            this.List = new List<MatchmakingPartnerType>();
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets or sets the list.
        /// </summary>
        [DataMember]
        public List<MatchmakingPartnerType> List { get; set; }

        /// <summary>
        /// Gets or sets the total row count.
        /// </summary>
        [DataMember]
        public int TotalRowCount { get; set; }

        #endregion
    }
}

namespace ServiceLibrary.Services.Commands
{
    using System.Runtime.Serialization;

    using NHibernate;

    using ServiceLibrary.Actioners.Activities;
    using ServiceLibrary.Services.Dto;

    using User = ServiceLibrary.Models.Domain.User;

    /// <summary>
    /// The create matchmaking partner type command.
    /// </summary>
    [DataContract]
    public class CreateMatchmakingPartnerTypeCommand : ICommand
    {
        #region Public Properties

        /// <summary>
        /// Gets or sets the new matchmaking partner type.
        /// </summary>
        [DataMember]
        public MatchmakingPartnerType NewMatchmakingPartnerType { get; set; }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="hsession">
        /// The hsession.
        /// </param>
        /// <param name="activeUser">
        /// The active user.
        /// </param>
        public override void Execute(ISession hsession, User activeUser)
        {
            var actioner = new MatchmakingPartnerActioner(hsession, activeUser);
            actioner.CreateMatchmakingPartnerType(this);
        }

        #endregion
    }
}